;$OJ=\chakan\obj\misc VB DA NOXR
	CSEG
	public	SChip
	public	Sound_On
	public	Sound_Off

	extern	Musical
	extern	chan_0
	extern	chan_1
	extern	chan_2
	extern	noise_chan
PSG	equ	0007fh

;////Sound Chip: RAM tables initialisation////

schip:
	ld	hl,chan_0+26
	ld	(hl),080h	;freq bits
	inc	hl
	ld	(hl),090h	;vol bits
	inc	hl
	ld	(hl),09fh	;chan off bits
	ld	hl,chan_1+26
	ld	(hl),0a0h
	inc	hl
	ld	(hl),0b0h
	inc	hl
	ld	(hl),0bfh
	ld	hl,chan_2+26
	ld	(hl),0c0h
	inc	hl
	ld	(hl),0d0h
	inc	hl
	ld	(hl),0dfh
	ld	hl,noise_chan+27
	ld	(hl),0f0h
	inc	hl
	ld	(hl),0ffh
	ret

;////// SOUND ON/OFF //////

sound_off:
	ld	a,(musical)
	res	7,a
	ld	(musical),a
	jr	kill_sound
sound_on:
	ld	a,(musical)
	set	7,a
	ld	(musical),a
	jr	kill_sound
kill_sound:
	ld	hl,clrtb	;kill sound chip
	ld	c,psg
	ld	b,4
	otir
	ret


clrtb:	db	9fh,0bfh,0dfh,0ffh

	END

